﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using DBUtility;//Please add references
namespace DAL
{
	/// <summary>
	/// 数据访问类:Appeal
	/// </summary>
	public partial class Appeal
	{
		public Appeal()
		{}
		#region  Method

		/// <summary>
		/// 得到最大ID
		/// </summary>
		public int GetMaxId()
		{
		return DbHelperSQL.GetMaxID("Id", "Appeal"); 
		}

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(int Id)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) from Appeal");
			strSql.Append(" where Id=@Id");
			SqlParameter[] parameters = {
					new SqlParameter("@Id", SqlDbType.Int,4)
			};
			parameters[0].Value = Id;

			return DbHelperSQL.Exists(strSql.ToString(),parameters);
		}


		/// <summary>
		/// 增加一条数据
		/// </summary>
		public int Add(Model.Appeal model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into Appeal(");
			strSql.Append("Name,Sex,Age,Birthday,Nationality,FamilyInfo,FamilyIncomeFrom,FamilyIncome,DistrictId,Address,PostalAddress,Demand,Teacher,School,Grade_Class,PhotoList,Guardian1,Guardian2,InsTime,FinishTime,IsPass1,IsReject1,IsPass2,IsReject2,InsertVolunteerId,CheckerId,VolunteerId,VolunteerIdStr,[From],IsDelete,IsPass)");
			strSql.Append(" values (");
			strSql.Append("@Name,@Sex,@Age,@Birthday,@Nationality,@FamilyInfo,@FamilyIncomeFrom,@FamilyIncome,@DistrictId,@Address,@PostalAddress,@Demand,@Teacher,@School,@Grade_Class,@PhotoList,@Guardian1,@Guardian2,@InsTime,@FinishTime,@IsPass1,@IsReject1,@IsPass2,@IsReject2,@InsertVolunteerId,@CheckerId,@VolunteerId,@VolunteerIdStr,@From,@IsDelete,@IsPass)");
			strSql.Append(";select @@IDENTITY");
			SqlParameter[] parameters = {
					new SqlParameter("@Name", SqlDbType.NVarChar,50),
					new SqlParameter("@Sex", SqlDbType.NVarChar,5),
					new SqlParameter("@Age", SqlDbType.Int,4),
					new SqlParameter("@Birthday", SqlDbType.DateTime),
					new SqlParameter("@Nationality", SqlDbType.NVarChar,20),
					new SqlParameter("@FamilyInfo", SqlDbType.NVarChar,1000),
					new SqlParameter("@FamilyIncomeFrom", SqlDbType.NVarChar,500),
					new SqlParameter("@FamilyIncome", SqlDbType.NVarChar,500),
					new SqlParameter("@DistrictId", SqlDbType.Int,4),
					new SqlParameter("@Address", SqlDbType.NVarChar,50),
					new SqlParameter("@PostalAddress", SqlDbType.NVarChar,100),
					new SqlParameter("@Demand", SqlDbType.NVarChar),
					new SqlParameter("@Teacher", SqlDbType.NVarChar,50),
					new SqlParameter("@School", SqlDbType.NVarChar,30),
					new SqlParameter("@Grade_Class", SqlDbType.NVarChar,30),
					new SqlParameter("@PhotoList", SqlDbType.NVarChar,500),
					new SqlParameter("@Guardian1", SqlDbType.NVarChar,50),
					new SqlParameter("@Guardian2", SqlDbType.NVarChar,50),
					new SqlParameter("@InsTime", SqlDbType.DateTime),
					new SqlParameter("@FinishTime", SqlDbType.DateTime),
					new SqlParameter("@IsPass1", SqlDbType.Bit,1),
					new SqlParameter("@IsReject1", SqlDbType.Bit,1),
					new SqlParameter("@IsPass2", SqlDbType.Bit,1),
					new SqlParameter("@IsReject2", SqlDbType.Bit,1),
					new SqlParameter("@InsertVolunteerId", SqlDbType.Int,4),
					new SqlParameter("@CheckerId", SqlDbType.Int,4),
					new SqlParameter("@VolunteerId", SqlDbType.Int,4),
					new SqlParameter("@VolunteerIdStr", SqlDbType.NVarChar,100),
					new SqlParameter("@From", SqlDbType.NVarChar,100),
					new SqlParameter("@IsDelete", SqlDbType.Bit,1),
					new SqlParameter("@IsPass", SqlDbType.Bit,1)};
			parameters[0].Value = model.Name;
			parameters[1].Value = model.Sex;
			parameters[2].Value = model.Age;
			parameters[3].Value = model.Birthday;
			parameters[4].Value = model.Nationality;
			parameters[5].Value = model.FamilyInfo;
			parameters[6].Value = model.FamilyIncomeFrom;
			parameters[7].Value = model.FamilyIncome;
			parameters[8].Value = model.DistrictId;
			parameters[9].Value = model.Address;
			parameters[10].Value = model.PostalAddress;
			parameters[11].Value = model.Demand;
			parameters[12].Value = model.Teacher;
			parameters[13].Value = model.School;
			parameters[14].Value = model.Grade_Class;
			parameters[15].Value = model.PhotoList;
			parameters[16].Value = model.Guardian1;
			parameters[17].Value = model.Guardian2;
			parameters[18].Value = model.InsTime;
			parameters[19].Value = model.FinishTime;
			parameters[20].Value = model.IsPass1;
			parameters[21].Value = model.IsReject1;
			parameters[22].Value = model.IsPass2;
			parameters[23].Value = model.IsReject2;
			parameters[24].Value = model.InsertVolunteerId;
			parameters[25].Value = model.CheckerId;
			parameters[26].Value = model.VolunteerId;
			parameters[27].Value = model.VolunteerIdStr;
			parameters[28].Value = model.From;
			parameters[29].Value = model.IsDelete;
			parameters[30].Value = model.IsPass;

			object obj = DbHelperSQL.GetSingle(strSql.ToString(),parameters);
			if (obj == null)
			{
				return 0;
			}
			else
			{
				return Convert.ToInt32(obj);
			}
		}
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(Model.Appeal model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update Appeal set ");
			strSql.Append("Name=@Name,");
			strSql.Append("Sex=@Sex,");
			strSql.Append("Age=@Age,");
			strSql.Append("Birthday=@Birthday,");
			strSql.Append("Nationality=@Nationality,");
			strSql.Append("FamilyInfo=@FamilyInfo,");
			strSql.Append("FamilyIncomeFrom=@FamilyIncomeFrom,");
			strSql.Append("FamilyIncome=@FamilyIncome,");
			strSql.Append("DistrictId=@DistrictId,");
			strSql.Append("Address=@Address,");
			strSql.Append("PostalAddress=@PostalAddress,");
			strSql.Append("Demand=@Demand,");
			strSql.Append("Teacher=@Teacher,");
			strSql.Append("School=@School,");
			strSql.Append("Grade_Class=@Grade_Class,");
			strSql.Append("PhotoList=@PhotoList,");
			strSql.Append("Guardian1=@Guardian1,");
			strSql.Append("Guardian2=@Guardian2,");
			strSql.Append("InsTime=@InsTime,");
			strSql.Append("FinishTime=@FinishTime,");
			strSql.Append("IsPass1=@IsPass1,");
			strSql.Append("IsReject1=@IsReject1,");
			strSql.Append("IsPass2=@IsPass2,");
			strSql.Append("IsReject2=@IsReject2,");
			strSql.Append("InsertVolunteerId=@InsertVolunteerId,");
			strSql.Append("CheckerId=@CheckerId,");
			strSql.Append("VolunteerId=@VolunteerId,");
			strSql.Append("VolunteerIdStr=@VolunteerIdStr,");
			strSql.Append("[From]=@From,");
			strSql.Append("IsDelete=@IsDelete,");
			strSql.Append("IsPass=@IsPass");
			strSql.Append(" where Id=@Id");
			SqlParameter[] parameters = {
					new SqlParameter("@Name", SqlDbType.NVarChar,50),
					new SqlParameter("@Sex", SqlDbType.NVarChar,5),
					new SqlParameter("@Age", SqlDbType.Int,4),
					new SqlParameter("@Birthday", SqlDbType.DateTime),
					new SqlParameter("@Nationality", SqlDbType.NVarChar,20),
					new SqlParameter("@FamilyInfo", SqlDbType.NVarChar,1000),
					new SqlParameter("@FamilyIncomeFrom", SqlDbType.NVarChar,500),
					new SqlParameter("@FamilyIncome", SqlDbType.NVarChar,500),
					new SqlParameter("@DistrictId", SqlDbType.Int,4),
					new SqlParameter("@Address", SqlDbType.NVarChar,50),
					new SqlParameter("@PostalAddress", SqlDbType.NVarChar,100),
					new SqlParameter("@Demand", SqlDbType.NVarChar),
					new SqlParameter("@Teacher", SqlDbType.NVarChar,50),
					new SqlParameter("@School", SqlDbType.NVarChar,30),
					new SqlParameter("@Grade_Class", SqlDbType.NVarChar,30),
					new SqlParameter("@PhotoList", SqlDbType.NVarChar,500),
					new SqlParameter("@Guardian1", SqlDbType.NVarChar,50),
					new SqlParameter("@Guardian2", SqlDbType.NVarChar,50),
					new SqlParameter("@InsTime", SqlDbType.DateTime),
					new SqlParameter("@FinishTime", SqlDbType.DateTime),
					new SqlParameter("@IsPass1", SqlDbType.Bit,1),
					new SqlParameter("@IsReject1", SqlDbType.Bit,1),
					new SqlParameter("@IsPass2", SqlDbType.Bit,1),
					new SqlParameter("@IsReject2", SqlDbType.Bit,1),
					new SqlParameter("@InsertVolunteerId", SqlDbType.Int,4),
					new SqlParameter("@CheckerId", SqlDbType.Int,4),
					new SqlParameter("@VolunteerId", SqlDbType.Int,4),
					new SqlParameter("@VolunteerIdStr", SqlDbType.NVarChar,100),
					new SqlParameter("@From", SqlDbType.NVarChar,100),
					new SqlParameter("@IsDelete", SqlDbType.Bit,1),
					new SqlParameter("@IsPass", SqlDbType.Bit,1),
					new SqlParameter("@Id", SqlDbType.Int,4)};
			parameters[0].Value = model.Name;
			parameters[1].Value = model.Sex;
			parameters[2].Value = model.Age;
			parameters[3].Value = model.Birthday;
			parameters[4].Value = model.Nationality;
			parameters[5].Value = model.FamilyInfo;
			parameters[6].Value = model.FamilyIncomeFrom;
			parameters[7].Value = model.FamilyIncome;
			parameters[8].Value = model.DistrictId;
			parameters[9].Value = model.Address;
			parameters[10].Value = model.PostalAddress;
			parameters[11].Value = model.Demand;
			parameters[12].Value = model.Teacher;
			parameters[13].Value = model.School;
			parameters[14].Value = model.Grade_Class;
			parameters[15].Value = model.PhotoList;
			parameters[16].Value = model.Guardian1;
			parameters[17].Value = model.Guardian2;
			parameters[18].Value = model.InsTime;
			parameters[19].Value = model.FinishTime;
			parameters[20].Value = model.IsPass1;
			parameters[21].Value = model.IsReject1;
			parameters[22].Value = model.IsPass2;
			parameters[23].Value = model.IsReject2;
			parameters[24].Value = model.InsertVolunteerId;
			parameters[25].Value = model.CheckerId;
			parameters[26].Value = model.VolunteerId;
			parameters[27].Value = model.VolunteerIdStr;
			parameters[28].Value = model.From;
			parameters[29].Value = model.IsDelete;
			parameters[30].Value = model.IsPass;
			parameters[31].Value = model.Id;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int Id)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from Appeal ");
			strSql.Append(" where Id=@Id");
			SqlParameter[] parameters = {
					new SqlParameter("@Id", SqlDbType.Int,4)
			};
			parameters[0].Value = Id;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		/// <summary>
		/// 批量删除数据
		/// </summary>
		public bool DeleteList(string Idlist )
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from Appeal ");
			strSql.Append(" where Id in ("+Idlist + ")  ");
			int rows=DbHelperSQL.ExecuteSql(strSql.ToString());
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public Model.Appeal GetModel(int Id)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select  top 1 Id,Name,Sex,Age,Birthday,Nationality,FamilyInfo,FamilyIncomeFrom,FamilyIncome,DistrictId,Address,PostalAddress,Demand,Teacher,School,Grade_Class,PhotoList,Guardian1,Guardian2,InsTime,FinishTime,IsPass1,IsReject1,IsPass2,IsReject2,InsertVolunteerId,CheckerId,VolunteerId,VolunteerIdStr,[From],IsDelete,IsPass from Appeal ");
			strSql.Append(" where Id=@Id");
			SqlParameter[] parameters = {
					new SqlParameter("@Id", SqlDbType.Int,4)
			};
			parameters[0].Value = Id;

			Model.Appeal model=new Model.Appeal();
			DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				if(ds.Tables[0].Rows[0]["Id"]!=null && ds.Tables[0].Rows[0]["Id"].ToString()!="")
				{
					model.Id=int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
				}
				if(ds.Tables[0].Rows[0]["Name"]!=null && ds.Tables[0].Rows[0]["Name"].ToString()!="")
				{
					model.Name=ds.Tables[0].Rows[0]["Name"].ToString();
				}
				if(ds.Tables[0].Rows[0]["Sex"]!=null && ds.Tables[0].Rows[0]["Sex"].ToString()!="")
				{
					model.Sex=ds.Tables[0].Rows[0]["Sex"].ToString();
				}
				if(ds.Tables[0].Rows[0]["Age"]!=null && ds.Tables[0].Rows[0]["Age"].ToString()!="")
				{
					model.Age=int.Parse(ds.Tables[0].Rows[0]["Age"].ToString());
				}
				if(ds.Tables[0].Rows[0]["Birthday"]!=null && ds.Tables[0].Rows[0]["Birthday"].ToString()!="")
				{
					model.Birthday=DateTime.Parse(ds.Tables[0].Rows[0]["Birthday"].ToString());
				}
				if(ds.Tables[0].Rows[0]["Nationality"]!=null && ds.Tables[0].Rows[0]["Nationality"].ToString()!="")
				{
					model.Nationality=ds.Tables[0].Rows[0]["Nationality"].ToString();
				}
				if(ds.Tables[0].Rows[0]["FamilyInfo"]!=null && ds.Tables[0].Rows[0]["FamilyInfo"].ToString()!="")
				{
					model.FamilyInfo=ds.Tables[0].Rows[0]["FamilyInfo"].ToString();
				}
				if(ds.Tables[0].Rows[0]["FamilyIncomeFrom"]!=null && ds.Tables[0].Rows[0]["FamilyIncomeFrom"].ToString()!="")
				{
					model.FamilyIncomeFrom=ds.Tables[0].Rows[0]["FamilyIncomeFrom"].ToString();
				}
				if(ds.Tables[0].Rows[0]["FamilyIncome"]!=null && ds.Tables[0].Rows[0]["FamilyIncome"].ToString()!="")
				{
					model.FamilyIncome=ds.Tables[0].Rows[0]["FamilyIncome"].ToString();
				}
				if(ds.Tables[0].Rows[0]["DistrictId"]!=null && ds.Tables[0].Rows[0]["DistrictId"].ToString()!="")
				{
					model.DistrictId=int.Parse(ds.Tables[0].Rows[0]["DistrictId"].ToString());
				}
				if(ds.Tables[0].Rows[0]["Address"]!=null && ds.Tables[0].Rows[0]["Address"].ToString()!="")
				{
					model.Address=ds.Tables[0].Rows[0]["Address"].ToString();
				}
				if(ds.Tables[0].Rows[0]["PostalAddress"]!=null && ds.Tables[0].Rows[0]["PostalAddress"].ToString()!="")
				{
					model.PostalAddress=ds.Tables[0].Rows[0]["PostalAddress"].ToString();
				}
				if(ds.Tables[0].Rows[0]["Demand"]!=null && ds.Tables[0].Rows[0]["Demand"].ToString()!="")
				{
					model.Demand=ds.Tables[0].Rows[0]["Demand"].ToString();
				}
				if(ds.Tables[0].Rows[0]["Teacher"]!=null && ds.Tables[0].Rows[0]["Teacher"].ToString()!="")
				{
					model.Teacher=ds.Tables[0].Rows[0]["Teacher"].ToString();
				}
				if(ds.Tables[0].Rows[0]["School"]!=null && ds.Tables[0].Rows[0]["School"].ToString()!="")
				{
					model.School=ds.Tables[0].Rows[0]["School"].ToString();
				}
				if(ds.Tables[0].Rows[0]["Grade_Class"]!=null && ds.Tables[0].Rows[0]["Grade_Class"].ToString()!="")
				{
					model.Grade_Class=ds.Tables[0].Rows[0]["Grade_Class"].ToString();
				}
				if(ds.Tables[0].Rows[0]["PhotoList"]!=null && ds.Tables[0].Rows[0]["PhotoList"].ToString()!="")
				{
					model.PhotoList=ds.Tables[0].Rows[0]["PhotoList"].ToString();
				}
				if(ds.Tables[0].Rows[0]["Guardian1"]!=null && ds.Tables[0].Rows[0]["Guardian1"].ToString()!="")
				{
					model.Guardian1=ds.Tables[0].Rows[0]["Guardian1"].ToString();
				}
				if(ds.Tables[0].Rows[0]["Guardian2"]!=null && ds.Tables[0].Rows[0]["Guardian2"].ToString()!="")
				{
					model.Guardian2=ds.Tables[0].Rows[0]["Guardian2"].ToString();
				}
				if(ds.Tables[0].Rows[0]["InsTime"]!=null && ds.Tables[0].Rows[0]["InsTime"].ToString()!="")
				{
					model.InsTime=DateTime.Parse(ds.Tables[0].Rows[0]["InsTime"].ToString());
				}
				if(ds.Tables[0].Rows[0]["FinishTime"]!=null && ds.Tables[0].Rows[0]["FinishTime"].ToString()!="")
				{
					model.FinishTime=DateTime.Parse(ds.Tables[0].Rows[0]["FinishTime"].ToString());
				}
				if(ds.Tables[0].Rows[0]["IsPass1"]!=null && ds.Tables[0].Rows[0]["IsPass1"].ToString()!="")
				{
					if((ds.Tables[0].Rows[0]["IsPass1"].ToString()=="1")||(ds.Tables[0].Rows[0]["IsPass1"].ToString().ToLower()=="true"))
					{
						model.IsPass1=true;
					}
					else
					{
						model.IsPass1=false;
					}
				}
				if(ds.Tables[0].Rows[0]["IsReject1"]!=null && ds.Tables[0].Rows[0]["IsReject1"].ToString()!="")
				{
					if((ds.Tables[0].Rows[0]["IsReject1"].ToString()=="1")||(ds.Tables[0].Rows[0]["IsReject1"].ToString().ToLower()=="true"))
					{
						model.IsReject1=true;
					}
					else
					{
						model.IsReject1=false;
					}
				}
				if(ds.Tables[0].Rows[0]["IsPass2"]!=null && ds.Tables[0].Rows[0]["IsPass2"].ToString()!="")
				{
					if((ds.Tables[0].Rows[0]["IsPass2"].ToString()=="1")||(ds.Tables[0].Rows[0]["IsPass2"].ToString().ToLower()=="true"))
					{
						model.IsPass2=true;
					}
					else
					{
						model.IsPass2=false;
					}
				}
				if(ds.Tables[0].Rows[0]["IsReject2"]!=null && ds.Tables[0].Rows[0]["IsReject2"].ToString()!="")
				{
					if((ds.Tables[0].Rows[0]["IsReject2"].ToString()=="1")||(ds.Tables[0].Rows[0]["IsReject2"].ToString().ToLower()=="true"))
					{
						model.IsReject2=true;
					}
					else
					{
						model.IsReject2=false;
					}
				}
				if(ds.Tables[0].Rows[0]["InsertVolunteerId"]!=null && ds.Tables[0].Rows[0]["InsertVolunteerId"].ToString()!="")
				{
					model.InsertVolunteerId=int.Parse(ds.Tables[0].Rows[0]["InsertVolunteerId"].ToString());
				}
				if(ds.Tables[0].Rows[0]["CheckerId"]!=null && ds.Tables[0].Rows[0]["CheckerId"].ToString()!="")
				{
					model.CheckerId=int.Parse(ds.Tables[0].Rows[0]["CheckerId"].ToString());
				}
				if(ds.Tables[0].Rows[0]["VolunteerId"]!=null && ds.Tables[0].Rows[0]["VolunteerId"].ToString()!="")
				{
					model.VolunteerId=int.Parse(ds.Tables[0].Rows[0]["VolunteerId"].ToString());
				}
				if(ds.Tables[0].Rows[0]["VolunteerIdStr"]!=null && ds.Tables[0].Rows[0]["VolunteerIdStr"].ToString()!="")
				{
					model.VolunteerIdStr=ds.Tables[0].Rows[0]["VolunteerIdStr"].ToString();
				}
				if(ds.Tables[0].Rows[0]["From"]!=null && ds.Tables[0].Rows[0]["From"].ToString()!="")
				{
					model.From=ds.Tables[0].Rows[0]["From"].ToString();
				}
				if(ds.Tables[0].Rows[0]["IsDelete"]!=null && ds.Tables[0].Rows[0]["IsDelete"].ToString()!="")
				{
					if((ds.Tables[0].Rows[0]["IsDelete"].ToString()=="1")||(ds.Tables[0].Rows[0]["IsDelete"].ToString().ToLower()=="true"))
					{
						model.IsDelete=true;
					}
					else
					{
						model.IsDelete=false;
					}
				}
				if(ds.Tables[0].Rows[0]["IsPass"]!=null && ds.Tables[0].Rows[0]["IsPass"].ToString()!="")
				{
					if((ds.Tables[0].Rows[0]["IsPass"].ToString()=="1")||(ds.Tables[0].Rows[0]["IsPass"].ToString().ToLower()=="true"))
					{
						model.IsPass=true;
					}
					else
					{
						model.IsPass=false;
					}
				}
				return model;
			}
			else
			{
				return null;
			}
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select Id,Name,Sex,Age,Birthday,Nationality,FamilyInfo,FamilyIncomeFrom,FamilyIncome,DistrictId,Address,PostalAddress,Demand,Teacher,School,Grade_Class,PhotoList,Guardian1,Guardian2,InsTime,FinishTime,IsPass1,IsReject1,IsPass2,IsReject2,InsertVolunteerId,CheckerId,VolunteerId,VolunteerIdStr,[From],IsDelete,IsPass ");
			strSql.Append(" FROM Appeal ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			return DbHelperSQL.Query(strSql.ToString());
		}

		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select ");
			if(Top>0)
			{
				strSql.Append(" top "+Top.ToString());
			}
			strSql.Append(" Id,Name,Sex,Age,Birthday,Nationality,FamilyInfo,FamilyIncomeFrom,FamilyIncome,DistrictId,Address,PostalAddress,Demand,Teacher,School,Grade_Class,PhotoList,Guardian1,Guardian2,InsTime,FinishTime,IsPass1,IsReject1,IsPass2,IsReject2,InsertVolunteerId,CheckerId,VolunteerId,VolunteerIdStr,[From],IsDelete,IsPass ");
			strSql.Append(" FROM Appeal ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			strSql.Append(" order by " + filedOrder);
			return DbHelperSQL.Query(strSql.ToString());
		}

		/// <summary>
		/// 获取记录总数
		/// </summary>
		public int GetRecordCount(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) FROM Appeal ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			object obj = DbHelperSQL.GetSingle(strSql.ToString());
			if (obj == null)
			{
				return 0;
			}
			else
			{
				return Convert.ToInt32(obj);
			}
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("SELECT * FROM ( ");
			strSql.Append(" SELECT ROW_NUMBER() OVER (");
			if (!string.IsNullOrEmpty(orderby.Trim()))
			{
				strSql.Append("order by T." + orderby );
			}
			else
			{
				strSql.Append("order by T.Id desc");
			}
			strSql.Append(")AS Row, T.*  from Appeal T ");
			if (!string.IsNullOrEmpty(strWhere.Trim()))
			{
				strSql.Append(" WHERE " + strWhere);
			}
			strSql.Append(" ) TT");
			strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
			return DbHelperSQL.Query(strSql.ToString());
		}

		/*
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		{
			SqlParameter[] parameters = {
					new SqlParameter("@tblName", SqlDbType.VarChar, 255),
					new SqlParameter("@fldName", SqlDbType.VarChar, 255),
					new SqlParameter("@PageSize", SqlDbType.Int),
					new SqlParameter("@PageIndex", SqlDbType.Int),
					new SqlParameter("@IsReCount", SqlDbType.Bit),
					new SqlParameter("@OrderType", SqlDbType.Bit),
					new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
					};
			parameters[0].Value = "Appeal";
			parameters[1].Value = "Id";
			parameters[2].Value = PageSize;
			parameters[3].Value = PageIndex;
			parameters[4].Value = 0;
			parameters[5].Value = 0;
			parameters[6].Value = strWhere;	
			return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
		}*/

		#endregion  Method
	}
}

